package com.example.demo.model.dto;

import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.List;

@Data
@Schema(description = "分页响应结果")
public class PageResult<T> {
    @Schema(description = "当前页码", example = "1")
    private int pageNum;

    @Schema(description = "每页数量", example = "10")
    private int pageSize;

    @Schema(description = "总记录数", example = "100")
    private long total;

    @Schema(description = "分页数据列表")
    private List<T> list;

    @Schema(description = "总页数", example = "10")
    private int pages;

    public PageResult(PageInfo<T> pageInfo) {
        this.pageNum = pageInfo.getPageNum();
        this.pageSize = pageInfo.getPageSize();
        this.total = pageInfo.getTotal();
        this.list = pageInfo.getList();
        this.pages = pageInfo.getPages();
    }
}